home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
041-050
/
amok49
/
oprof
/
txt
/
hilbert.prf
< prev
next >
Wrap
Text File
|
1993-11-04
|
5KB
|
217 lines
(* OProf ©1990 by Volker Rudolph *)
(*
:Program. Hilbert
:Author. Volker Rudolph
:Address. Lettow-Vorbeck-Str. 11 / 6750 Kaiserslautern 26
:Phone. 06301/8566
:Version. 1.0
:Date. 23.7.90
:Copyright. PD
:Language. Oberon
:Translator. Amiga-Oberon V1.14
:Contents. Zeichnet Hilbert-Kurven
*)
MODULE Hilbert;
IMPORT prof:ProfRunTime,e:Exec,i:Intuition,g:Graphics,Break,n:NoGuru,s:SYSTEM;
CONST
ScreenWidth = 350;
ScreenHeight = 282;
SquareSize = 256;
VAR
sc:i.ScreenPtr;
wi:i.WindowPtr;
msg:e.MsgPortPtr;
(* -------------------------------------------------------------------------- *)
PROCEDURE WaitForClick;
BEGIN
prof.Entry("Hilbert.WaitForClick",266);
e.WaitPort(wi.userPort);
msg := e.GetMsg(wi.userPort);
e.WaitPort(wi.userPort);
msg := e.GetMsg(wi.userPort);
prof.Exit("Hilbert.WaitForClick",266);
END WaitForClick;
PROCEDURE CreateGraphics;
VAR
ns:i.NewScreen;
nw:i.NewWindow;
BEGIN
prof.Entry("Hilbert.CreateGraphics",464);
ns.leftEdge := 0;
ns.topEdge := 0;
ns.width := ScreenWidth;
ns.height := ScreenHeight;
ns.depth := 3;
ns.detailPen := 1;
ns.blockPen := 2;
ns.viewModes := {};
ns.type := i.customScreen;
ns.font := NIL;
ns.defaultTitle := NIL;
ns.gadgets := NIL;
ns.customBitMap := NIL;
sc := i.OpenScreen(ns);
n.Assert(sc # NIL,"Can't open screen");
nw.leftEdge := 0;
nw.topEdge := 0;
nw.width := ScreenWidth;
nw.height := ScreenHeight;
nw.detailPen := 1;
nw.blockPen := 2;
nw.idcmpFlags := LONGSET{i.mouseButtons};
nw.flags := LONGSET{i.borderless};
nw.firstGadget := NIL;
nw.checkMark := NIL;
nw.title := NIL;
nw.screen := sc;
nw.bitMap := NIL;
nw.minWidth := 0;
nw.minHeight := 0;
nw.maxWidth := ScreenHeight;
nw.maxHeight := ScreenHeight;
nw.type := i.customScreen;
wi := i.OpenWindow(nw);
n.Assert(wi # NIL,"Can't open window");
g.SetRGB4(s.ADR(sc.viewPort),2,15,15,0);
prof.Exit("Hilbert.CreateGraphics",464);
END CreateGraphics;
PROCEDURE RemoveGraphics;
BEGIN
prof.Entry("Hilbert.RemoveGraphics",62);
IF wi # NIL THEN
i.CloseWindow(wi);
wi := NIL;
END; (* IF *)
IF sc # NIL THEN
i.CloseScreen(sc);
sc := NIL;
END; (* IF *)
prof.Exit("Hilbert.RemoveGraphics",62);
END RemoveGraphics;
PROCEDURE Line(direction,delta:INTEGER);
BEGIN
prof.Entry("Hilbert.Line",788);
CASE direction OF
0:g.Draw(wi.rPort,wi.rPort.x+delta,wi.rPort.y);
|2:g.Draw(wi.rPort,wi.rPort.x,wi.rPort.y-delta);
|4:g.Draw(wi.rPort,wi.rPort.x-delta,wi.rPort.y);
|6:g.Draw(wi.rPort,wi.rPort.x,wi.rPort.y+delta);
ELSE
n.Assert(FALSE,"Wrong direction");
END; (* CASE *)
prof.Exit("Hilbert.Line",788);
END Line;
(* -------------------------------------------------------------------------- *)
PROCEDURE Hilbert;
VAR
i,x0,y0,u:INTEGER;
PROCEDURE ^A(i:INTEGER);
PROCEDURE ^B(i:INTEGER);
PROCEDURE ^C(i:INTEGER);
PROCEDURE ^D(i:INTEGER);
PROCEDURE A(i:INTEGER);
BEGIN
prof.Entry("Hilbert.Hilbert.A",827);
IF i > 0 THEN
D(i-1); Line(4,u);
A(i-1); Line(6,u);
A(i-1); Line(0,u);
B(i-1);
END; (* IF *)
prof.Exit("Hilbert.Hilbert.A",827);
END A;
PROCEDURE B(i:INTEGER);
BEGIN
prof.Entry("Hilbert.Hilbert.B",828);
IF i > 0 THEN
C(i-1); Line(2,u);
B(i-1); Line(0,u);
B(i-1); Line(6,u);
A(i-1);
END; (* IF *)
prof.Exit("Hilbert.Hilbert.B",828);
END B;
PROCEDURE C(i:INTEGER);
BEGIN
prof.Entry("Hilbert.Hilbert.C",829);
IF i > 0 THEN
B(i-1); Line(0,u);
C(i-1); Line(2,u);
C(i-1); Line(4,u);
D(i-1);
END; (* IF *)
prof.Exit("Hilbert.Hilbert.C",829);
END C;
PROCEDURE D(i:INTEGER);
BEGIN
prof.Entry("Hilbert.Hilbert.D",830);
IF i > 0 THEN
A(i-1); Line(6,u);
D(i-1); Line(4,u);
D(i-1); Line(2,u);
C(i-1);
END; (* IF *)
prof.Exit("Hilbert.Hilbert.D",830);
END D;
BEGIN
prof.Entry("Hilbert.Hilbert",47);
x0 := ScreenWidth DIV 2;
y0 := ScreenHeight DIV 2;
u := SquareSize;
i := 0;
REPEAT
INC(i);
u := u DIV 2;
x0 := x0 + (u DIV 2);
y0 := y0 + (u DIV 2);
g.SetAPen(wi.rPort,i);
g.Move(wi.rPort,x0,ScreenHeight-y0);
A(i);
(* WaitForClick; *)
UNTIL (i = 6);
prof.Exit("Hilbert.Hilbert",47);
END Hilbert;
(* -------------------------------------------------------------------------- *)
BEGIN
prof.Entry("Hilbert",740);
CreateGraphics;
Hilbert;
WaitForClick;
prof.Exit("Hilbert",740);
CLOSE
RemoveGraphics;
END Hilbert.